<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CircleCardPrice extends Model
{
    protected $dateFormat = 'U';
    protected $table = "lexiang_circle_card_price";
    protected $primaryKey = 'circle_price_id';

    public function add($data)
    {
    	$cirdata = $this->where('circle_id',$data['circle_id'])->first();
    	if($cirdata){
    		$this_ = $cirdata;
    	}else{
    		$this_ = $this;
    	}
    	$this_->circle_id = $data['circle_id'];
    	$this_->card_id = $data['card_id'];
    	$this_->price = $data['price'];

    	if($this_->save()){
    		return [
    			'success'=>true,
    			'code'=>'000',
    			'message'=>'修改成功'
    		];
    	}else{
    		return [
    			'success'=>false,
    			'code'=>'003',
    			'message'=>'修改出错，请稍后再试！'
    		];
    	}
    }
}
